<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <div>
   <h3>Hello Spring Cloud Alibaba</h3>
   <button onclick="doBuy()">buy</button>
   <span id="result"></span>
  </div>
  <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  <!-- 本地引入方式
  <script src="/js/axios.min.js"></script>
  -->
  <script>
      function doBuy(){
          debugger
          //1.定义请求url
          let url="http://localhost:9000/nacos/provider/echo/1";
          //2.发送ajax请求
          let span=document.getElementById("result");
          axios.get(url)
               .then(function(result){
                   console.log("then:{}",result);
                   span.innerHTML=result.data;
               })
               .catch(function(error){
                   console.log("catch:{}",error);
                   if(error.response.status==429){
                       span.innerHTML=error.response.statusText;
                   }
               })
      }
  </script>
</body>
</html>